package tt.databaseutils;

import tt.global.GlobalConstants;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DbUtils extends SQLiteOpenHelper {
	private static final String SQL_IMPORTEDBOOKS_CREATE = "create table "
			+ GlobalConstants.TABLENAME_IMPORTED + "("
			+ GlobalConstants.IMPORTED_ID + " INTEGER PRIMARY KEY,"
			+ GlobalConstants.IMPORTED_BOOK_NAME + " TEXT,"
			+ GlobalConstants.IMPORTED_BOOK_AUTHOR + " TEXT,"
			+ GlobalConstants.IMPORTED_BOOK_PATH + " TEXT,"
			+ GlobalConstants.IMPORTED_RECENTLY + " INTEGER)";

	public DbUtils(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
		// TODO Auto-generated constructor stub
	}

	public DbUtils(Context context, String name, int version) {
		this(context, name, null, version);
		// TODO Auto-generated constructor stub
	}

	public DbUtils(Context context, String name) {
		this(context, name, GlobalConstants.DATABASE_VERSION);
		// TODO Auto-generated constructor stub
	}

	public DbUtils(Context context) {
		this(context, GlobalConstants.DATABASE_NAME,
				GlobalConstants.DATABASE_VERSION);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		/*
		 * String sqlStrFav = "create table " +
		 * GlobalConstants.DATABASE_TABLENAME_FAVORITES +
		 * "(_id INTEGER PRIMARY KEY,book_name TEXT,book_author TEXT,book_path TEXT,recently INTEGER)"
		 * ; String sqlStrImp = "create table " +
		 * GlobalConstants.DATABASE_TABLENAME_IMPORTED +
		 * "(_id INTEGER PRIMARY KEY,book_name TEXT,book_author TEXT,book_path TEXT)"
		 * ; String sqlStrBookmarks="create table " +
		 * GlobalConstants.DATABASE_TABLENAME_BOOKMARKS +
		 * "(_id INTEGER PRIMARY KEY,book_name TEXT,book_author TEXT,book_path TEXT)"
		 * ;
		 */
		// db.execSQL(sqlStrFav);
		db.execSQL(SQL_IMPORTEDBOOKS_CREATE);
		// db.execSQL(sqlStrBookmarks);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub

	}

}
